﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web;
using PlexBB.Controls;
using PlexBB.Data;
//using PlexBB.Actions;
namespace PlexBB.Controls
{
    public abstract class ForumListBody : ForumControl
    {
        protected HyperLink mainLink;
        //protected Repeater forumRows;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            if (mainLink != null)
            {
                string url = PlexBBContext.CreateUrl("acp");

                mainLink.NavigateUrl = url;
                mainLink.Text = url;

                mainLink.Text = "ASDASD";
            }

            //mainLink.Text += plexBB.Data.DatabaseExists();

            //User u = new User() { };
            //plexBB.Data.Users.InsertOnSubmit(u);
            //u.SetPassword("somepass");

            //plexBB.Data.SubmitChanges();

            //User u1 = (from user in plexBB.Data.Users
            //         where user.UserID == u.UserID
            //         select user).Single();

            //if (!u1.ValidatePassword("somepass"))
            //    throw new Exception();

            //int[] a = { 1, 2, 3 };

            //Forums = new ForumData[] { 
            //                             new ForumData(),new ForumData(){S_FIRST_ROW=true},new ForumData(),
            //                         };

            ////            forumRows.GetType().GetProperty("DataSource").SetValue(forumRows, data, null);
            //forumRows.DataSource = data;
            //forumRows.DataBind();
        }

        protected object Categories;


        protected ForumData Forum
        {
            get { return (ForumData)Page.GetDataItem(); }
        }
        protected CategoryData Category
        {
            get { return (CategoryData)Page.GetDataItem(); }
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //if (!_dataBound)
            //{
            //    DataBind();
            //}
        }
        //private bool _dataBound;
        //public override void DataBind()
        //{
        //    base.DataBind();
        //    _dataBound = true;
        //}
    }

    //public interface IDataBoundControl
    //{
    //    object DataSource { get; set; }
    //    void DataBind();

    //}
    public struct ForumData
    {
        public bool S_IS_CAT;
        public bool S_FIRST_ROW;
        public bool S_NO_CAT;
    }

    public struct CategoryData
    {
        public ForumData[] Forums;
    }
}
